<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*,database.DBCon" %>
<%!
    public void check(String[] arr) {
        for (int i = 0; i < arr.length; i++) {
            while (arr[i] != null && arr[i].indexOf("\n") != -1) {
                arr[i] = arr[i].substring(0, arr[i].indexOf("\n") - 1) + "<br/>" + arr[i].substring(arr[i].indexOf("\n") + 1, arr[i].length());
            }
        }
    }
%>
<%
try{
            DBCon db1 = new DBCon();
            int size = db1.countProjects(" WHERE status = 'accepted'");

            String[] id = new String[size];
            String[] title = new String[size];
            String[] desc = new String[size];
            String[] po = new String[size];
            String[] rb = new String[size];
            String[] tn = new String[size];
            String[] dl = new String[size];
            String[] pt = new String[size];
            String[] pk = new String[size];
            String[] er = new String[size];
            String[] ac = new String[size];
            String[] pName = new String[size];
            
            ResultSet res = db1.getProjectsValidated();
            for (int i = 0; res.next(); i++) {
                id[i] = res.getString("id");
                title[i] = res.getString("title");
                desc[i] = res.getString("Description");
                po[i] = res.getString("Project_Objectives");
                rb[i] = res.getString("Required_Background");
                tn[i] = res.getString("Tools_Needed");
                dl[i] = res.getString("Difficulty_Level");
                pt[i] = res.getString("Project_Type");
                pk[i] = res.getString("Project_Keywords");
                er[i] = res.getString("Expected_Results");
                ac[i] = res.getString("Additional_Comments");
                pName[i] = res.getString("firstName") + " " + res.getString("lastName");

            }

            check(desc);
            check(pName);
            check(po);
            check(rb);
            check(tn);
            check(dl);
            check(pt);
            check(pk);
            check(er);
            check(ac);


            out.println("<script type='text/javascript'>");
            out.println("function init() {");
            for (int i = 0; i < size; i++) {
                out.println("descriptions[" + i + "] = new Desc();");
                out.println("descriptions[" + i + "].id = '" + (id[i] != null ? id[i] : "") + "';");
                out.println("descriptions[" + i + "].t = '" + (title[i] != null ? title[i] : "") + "';");
                out.println("descriptions[" + i + "].pName = '" + (pName[i] != null ? pName[i] : "") + "';");
                out.println("descriptions[" + i + "].description = '" + (desc[i] != null ? desc[i] : "") + "';");
                out.println("descriptions[" + i + "].po = '" + (po[i] != null ? po[i] : "") + "';");
                out.println("descriptions[" + i + "].rb = '" + (rb[i] != null ? rb[i] : "") + "';");
                out.println("descriptions[" + i + "].tn = '" + (tn[i] != null ? tn[i] : "") + "';");
                out.println("descriptions[" + i + "].dl = '" + (dl[i] != null ? dl[i] : "") + "';");
                out.println("descriptions[" + i + "].pk = '" + (pk[i] != null ? pk[i] : "") + "';");
                out.println("descriptions[" + i + "].er = '" + (er[i] != null ? er[i] : "") + "';");
                out.println("descriptions[" + i + "].er = '" + (er[i] != null ? er[i] : "") + "';");


            }
            out.println("}");
            out.println("</script>");
%>


<div id="rightMenu" style="position:absolute"></div>
<table style="text-align: left" border="0" width="100%" cellspacing="0" cellpadding="0" class="all">
    <%

            for (int i = 0; i < id.length; i++) {
    %>
    <tr>
        <td id="td<%=i%>" valign="top" class="normal">
            <div id="ccc<%=i%>">
            <div id="title<%=i%>" class="title" width="100%" onMouseOver="mouse(<%=i%>)" onMouseOut="mouseo(<%=i%>)" onclick="clicked(<%=i%>)">
            
            </div> 
            </div>
            
        </td>
        
    </tr>
    
    <%
            }
    }
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}

    %>
    
</table>